package org.winexpress

import grails.converters.deep.JSON
import org.codehaus.groovy.grails.web.json.JSONObject;
import org.codehaus.groovy.grails.web.json.JSONArray;

class ProductController {

    // initialization: GSP support operations (must be same as GSP filename)
    def memberRegistration = {
        // consume winexpress server web service
        def txt = new URL("http://localhost:8080/WineXpress/country").text
        
        JSONArray arr  = new JSONArray(txt)
        ArrayList<Country> countryList = new ArrayList<Country>()
    
        arr.each()
        {
           Country c = new Country()
           c.countryName = it.countryName
           c.id = it.id
           countryList.add(c)
        }
//        countryList.each()
//        {
//            println it
//        }
        
        [countries:countryList]
    }
    
}
